home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / jpl_c.zip / GETF.C < prev    next >
Text File  |  1986-05-18  |  1KB  |  33 lines

  1. /* 1.1  01-08-86                        (getf.c)
  2. /************************************************************************
  3.  *            Robert C. Tausworthe                *
  4.  *            Jet Propulsion Laboratory            *
  5.  *            Pasadena, CA 91009        1986        *
  6.  ************************************************************************/
  7.  
  8. #include "defs.h"
  9. #include "stdtyp.h"
  10. #include "stdio.h"
  11.  
  12. /************************************************************************/
  13.     double
  14. getf(prompt, check, low, high)    /* Print prompt on stdout, then get and
  15.                    return double input from stdin.  If
  16.                    check is true, verify within bounds.    */
  17. /*----------------------------------------------------------------------*/
  18. STRING prompt;
  19. BOOL check;
  20. double low, high;
  21. {
  22.     double value, atof();
  23.     char s[MAXLINE];
  24.  
  25.     FOREVER
  26.     {    value = atof(getns(prompt, s, MAXLINE - 1));
  27.         if (NOT check OR (low <= value AND value <= high))
  28.             break;
  29.         putstr("\nValue out of range, please reenter.\n");
  30.     }
  31.     return (value);
  32. }
  33.